package practical_projects.games.submarine_war;

import javax.swing.ImageIcon;
import java.util.LinkedList;

public class Bomb extends Weapon {     // 炸弹
    public Bomb(int x, int y) {
        super(9, 12, x, y, 3);
    }

    @Override
    public void move() {
        y += speed;
    }

    @Override
    public ImageIcon getImage() {
        return Images.bomb;
    }

    public Submarine collisionDetection(LinkedList<Submarine> submarineList) {     // 碰撞检测
        for (Submarine submarine : submarineList) {
            if ( submarine.isLive() &&
                    y + height >= submarine.y && y <= submarine.y + submarine.height &&
                    x + width >= submarine.x && x <= submarine.x + submarine.width)
                return submarine;
        }
        return null;
    }
}
